<%@ page import="com.example.rk.entity.Admin" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html lang="en">

<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>XXXX后端管理系统</title>
    <jsp:include page="../common_css.jsp"/>

</head>
<body>
<div class="container-scroller">
    <!-- partial:partials/_navbar.html -->
    <jsp:include page="../top.jsp"/>

    <!-- partial -->
    <div class="container-fluid page-body-wrapper">
        <!-- partial:partials/_sidebar.html -->
        <jsp:include page="./left.jsp"/>
        <!-- partial -->
        <div class="main-panel">
            <div class="row">
                <div class="col-md-12 stretch-card">
                    <div class="card">
                        <div class="card-body">

                        <div class="table-responsive">
                                <form id="frm" class="form-signin">
                                    <img class="mb-4" src="/upload/${admin.imageUrl}"  alt="" width="72" height="72">
                                    <input type="button" value="修改头像" onclick="window.location.href='/jsp/gly/changeadd.jsp'">
                                    <h1 class="h3 mb-3 font-weight-normal">个人信息设置</h1>
                                    <label for="inputname" class="sr-only">账号</label>
                                    <input type="text" id="inputname" name="name" value="${admin.name}"   class="form-control" placeholder="账号" required autofocus>
                                    <label for="inputpwd" class="sr-only">密码</label>
                                    <input type="text" id="inputpwd"  name="pwd"  value="${admin.pwd}" class="form-control" placeholder="密码" required>
                                    <label for="inputtype" class="sr-only">类型</label>
                                    <input type="text" id="inputtype"  name="type" value="${admin.type}" class="form-control" placeholder="类型" >
                                    <label for="inputphone" class="sr-only">手机号</label>
                                    <input type="text" id="inputphone"  name="phone" value="${admin.phone}" class="form-control" placeholder="手机号" >
                                    <input type="hidden" id="inputid" name="id" value="${admin.id}" class="form-control" placeholder="ID" >
                                    <button class="btn btn-lg btn-primary btn-block" type="button" onclick="doEdit()" style="width: 30%">编辑</button>
                                </form>

                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>


        <jsp:include page="../footer.jsp"/>
    </div>
    <!-- main-panel ends -->
</div>
<!-- page-body-wrapper ends -->
</div>
<!-- container-scroller -->
<jsp:include page="../common_js.jsp"/>
</body>

</html>
<script>
    function doEdit() {
        $.ajax(
            {
                type:"post",
                url:"/admin/doEdit",
                data:$("#frm").serialize(),
                async:false,  //使用ajax同步提交数据
                success:function (response) {
                    if (response=="false"){
                        alert("修改失败");
                    }else  if (response=="ok"){
                        alert("修改成功");
                        setTimeout(window.location.href="/admin/main",1000);
                    }
                }
            }
        );
    }
</script>
